<?php
declare (strict_types = 1);

namespace app\admin\validate\system;

use think\Validate;

class Menu extends Validate
{
    /**
     * 定义验证规则
     * 格式：'字段名'	=>	['规则1','规则2'...]
     * @var array
     */
    protected $rule = [
	    'title|名称' => 'require|min:2|unique:system_menu',
        'href|地址' => 'require|min:2',
        'module|模块' => 'require|min:2',
        'type|类型' => 'require',
        'sort|排序' => 'require|number|between:1,200',
    ];

    /**
     * 定义错误信息
     * 格式：'字段名.规则名'	=>	'错误信息'
     *
     * @var array
     */
    protected $message = [
        'title.unique' => '菜单已存在'
    ];

    // edit 验证场景定义
    public function sceneEdit()
    {
    	return $this->only(['title','href','type','sort','module'])
        ->remove('title','unique');
    }  
}
